/**
 * 
 */
package xhe.lib.io;

import java.util.HashMap;
import java.util.Map;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

/**
 * 功能：加解密Xml工具类-dom4j 版 本:王立栓/2020年4月14日/
 */
public class Xml {

	public static Map<String, String> getXmlValue(String xml, String method, String key1, String key2, String key3)
			throws Exception {
		Document doc = null;
		Map<String, String> map = new HashMap<String, String>();
		doc = DocumentHelper.parseText(xml);
		Element rootElt = doc.getRootElement(); // 获取根节点
		Element body = rootElt.element("Body");
		Element response = body.element(method + "Response");
		if (!"".equals(key1)) {
			Element element1 = response.element(key1);
			map.put(key1, String.valueOf(element1.getData()));
		}
		if (!"".equals(key2)) {
			Element element2 = response.element(key2);
			map.put(key2, String.valueOf(element2.getData()));
		}
		if (!"".equals(key3)) {
			Element element3 = response.element(key3);
			map.put(key3, String.valueOf(element3.getData()));
		}
		return map;
	}
}
